package com.leetCode.solution1;

/**
 * 用递归的方式删除
 */
public class Solution3 {
    public ListNode removeElements(ListNode head, int val) {
        if (head == null) {
            return null;
        }
        ListNode listNode = removeElements(head.next, val);
        if (head.val != val) {
            head.next = listNode;
        }else {
            head = listNode;
        }
        return head;
    }
}
